use std::collections::HashMap;
impl Solution {
    pub fn group_the_people(group_sizes: Vec<i32>) -> Vec<Vec<i32>> {
        let mut mp = HashMap::<i32,Vec<i32>>::new();
        for(i,v)in group_sizes.iter().enumerate() {
            mp.entry(*v).and_modify(|x|x.push(i as i32)).or_insert(Vec::from([i as i32]));
        };
        let mut ans =Vec::<Vec<i32>>::new();
        for (k,v) in mp{
            for c in v.chunks(k as usize){
                ans.push(c.to_owned())
            }   
        };
        ans


    }
}